﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;

namespace Gadgeteer.Modules.Community.XBee.Test.Unit
{
    [TestClass]
    public class ConvertTests
    {
        [TestMethod]
        public void ToUShort()
        {
            byte[] myAddress = new byte[2] {  0x86, 0x72 };
            ushort result = Converter.ToUShort(myAddress);
            Debug.WriteLine(Convert.ToString(0x86, 2));
            Debug.WriteLine(Convert.ToString(0x72, 2));
            Debug.WriteLine(Convert.ToString((Int64)result, 2));
            byte[] output = Converter.ToByteArray(result);
            Assert.AreEqual(0x86, output[0]);
            Assert.AreEqual(0x72, output[1]);
        }

        [TestMethod]
        public void ToUInt()
        {
            byte[] myAddress = new byte[4] { 0x40, 0x8A, 0x86, 0x72 };
            uint result = Converter.ToUInt(myAddress);
            Debug.WriteLine(Convert.ToString(0x40, 2));
            Debug.WriteLine(Convert.ToString(0x8A, 2));
            Debug.WriteLine(Convert.ToString(0x86, 2));
            Debug.WriteLine(Convert.ToString(0x72, 2));
            Debug.WriteLine(Convert.ToString((Int32)result, 2));
            byte[] output = Converter.ToByteArray(result);
            Assert.AreEqual(0x40, output[0]);
            Assert.AreEqual(0x8A, output[1]);
            Assert.AreEqual(0x86, output[2]);
            Assert.AreEqual(0x72, output[3]);
        }
    }
}
